/// <summary>
/// 支付工厂
/// </summary>
public class PaymentFactory
{
  public enum PaymentType
  {
    Alipay,
    WeChatPay,
    BankCard
  }

  /// <summary>
  /// 创建支付实例
  /// </summary>
  /// <param name="type">支付类型</param>
  /// <returns>支付实例</returns>
  public static IPayment CreatePayment(PaymentType type)
  {
    return type switch
    {
      PaymentType.Alipay => new Alipay(),
      PaymentType.WeChatPay => new WeChatPay(),
      PaymentType.BankCard => new BankCardPay(),
      _ => throw new ArgumentException("不支持的支付方式")
    };
  }
}